package logic.collegeQuery_logic;

import java.util.LinkedList;
import java.util.List;

import javaRMI.RMIClient;
import logic.utility_logic.CourseProduceLogicsvFactory;
import logicsv.courseProduce_logicsv.CourseProduceLogicsv;
import resultmessage.CollegeQueryRM;
import vo.CourseVO;
import datasv.collegeQuery_datasv.CollegeQueryDatasv;
import datasv.datafactorysv.CollegeQueryDatasvFactory;

public class CourseQuery implements CourseQuerysv {
	private CollegeQueryDatasv collegeQD;
	private CourseProduceLogicsv coursePL;
	public CourseQuery(RMIClient rmi){
		collegeQD = new CollegeQueryDatasvFactory(rmi).create();
		coursePL = new CourseProduceLogicsvFactory(rmi).create();
	}
	@Override
	public CollegeQueryRM deleteCourse(String collegeID, String courseID) {
		return collegeQD.deleteCourse(collegeID, courseID);
	}
	@Override
	public CollegeQueryRM addCourse(String collegeID, String courseID,
			String courseName) {
		return collegeQD.addCourse(collegeID, courseName, courseID);
	}
	@Override
	public List<CourseVO> getCouOfCollege(String collegeID) {
		List<String> courses = collegeQD.getCouOfCollege(collegeID);
		LinkedList<CourseVO> list= new LinkedList<CourseVO>();
		for(String courseID : courses){
			list.add(coursePL.getCourse(courseID));
		}
		return list;
	}

}
